/*
 * Copyright (c) 2013 by Chances.
 * $CVSHeader$
 * $Author$
 * $Date$
 * $Revision$
 */
package chances.epg.navigator.context;

import org.springframework.util.StringUtils;

import chances.epg.config.EpgSiteContext;
import chances.epg.entity.biz.Biz;

/**
 * Class comments.
 *
 * @author <a href="mailto:libf@chances.com.cn">libf</a>
 */
public class AccessContext {
	public static final String CATEGORY_CONTAINER_TYPE = "category";
	public static final String POSITION_CONTAINER_TYPE = "position";

	public static final int DIRECT_FLAG = 1;

	protected String serverName;
	protected int serverPort;

	protected String tranId; // 请求序列号

	protected String siteCode;
	protected String bizCode;
	protected Biz biz;

	// category/position
	protected String containerType;
	protected String containerCode;
	protected Long itemId;
	protected String itemIndex;

	// subject/album
	protected String parentContentType;
	protected String parentContentCode;

	// vod/series/channel
	protected String contentType;
	protected String contentCode;

	// 是否跳转链接
	protected int direct = 0;



	protected EpgSiteContext epgSiteContext;

	public AccessContext() {
		this.siteCode = "";
		this.bizCode = "";
		this.containerType = "";
		this.containerCode = "";
		this.itemIndex = "";
		this.parentContentType = "";
		this.parentContentCode = "";
		this.contentType = "";
		this.contentCode = "";
	}

	/**
	 * 是否栏目容器.
	 * 
	 * @return
	 */
	public boolean isCateoryContainer() {
		return CATEGORY_CONTAINER_TYPE.equals(this.getContainerType());
	}

	/**
	 * 是否推荐位容器.
	 * 
	 * @return
	 */
	public boolean isPositionContainer() {
		return POSITION_CONTAINER_TYPE.equals(this.getContainerType());
	}

	public String getSiteRoot() {
		String result = epgSiteContext.getSiteRoot();
		if(StringUtils.isEmpty(result)){
			return this.siteCode;
		}else{
			return epgSiteContext.getSiteRoot();
		}
	}

	/**
	 * @return the tranId
	 */
	public String getTranId() {
		return tranId;
	}

	/**
	 * @param tranId
	 *            the tranId to set
	 */
	public void setTranId(String tranId) {
		this.tranId = tranId;
	}

	public String getSiteCode() {
		return siteCode;
	}

	public void setSiteCode(String siteCode) {
		this.siteCode = siteCode;
	}

	public String getBizCode() {
		return bizCode;
	}

	public void setBizCode(String bizCode) {
		this.bizCode = bizCode;
	}

	public String getContainerType() {
		return containerType;
	}

	public void setContainerType(String containerType) {
		this.containerType = containerType;
	}

	public String getContainerCode() {
		return containerCode;
	}

	public void setContainerCode(String containerCode) {
		this.containerCode = containerCode;
	}

	public String getParentContentType() {
		return parentContentType;
	}

	public void setParentContentType(String parentContentType) {
		this.parentContentType = parentContentType;
	}

	public String getParentContentCode() {
		return parentContentCode;
	}

	public void setParentContentCode(String parentContentCode) {
		this.parentContentCode = parentContentCode;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public String getContentCode() {
		return contentCode;
	}

	public void setContentCode(String contentCode) {
		this.contentCode = contentCode;
	}

	public Long getItemId() {
		return itemId;
	}

	public void setItemId(Long itemId) {
		this.itemId = itemId;
	}

	public String getItemIndex() {
		return itemIndex;
	}

	public void setItemIndex(String itemIndex) {
		this.itemIndex = itemIndex;
	}

	public int getDirect() {
		return direct;
	}

	public EpgSiteContext getEpgSiteContext() {
		return epgSiteContext;
	}

	public void setDirect(int direct) {
		this.direct = direct;
	}

	public Biz getBiz() {
		return biz;
	}

	public void setBiz(Biz biz) {
		this.biz = biz;
	}

	public boolean isRedirect() {
		return this.direct == DIRECT_FLAG;
	}

	public void setEpgSiteContext(EpgSiteContext epgSiteContext2) {
		this.epgSiteContext = epgSiteContext2;
	}

}
